package org.dromara.hotel.mapper;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.dromara.hotel.domain.TerPricingRule;
import org.dromara.hotel.domain.vo.TerPricingRuleVo;
import org.dromara.common.mybatis.core.mapper.BaseMapperPlus;

import java.time.LocalDate;
import java.util.List;

/**
 * 酒店价格规则Mapper接口
 *
 * @author xch
 * @date 2025-06-10
 */
public interface TerPricingRuleMapper extends BaseMapperPlus<TerPricingRule, TerPricingRuleVo> {
    @Select("SELECT * FROM ter_pricing_rule " +
        "WHERE room_id = #{roomTypeId} " +
        "AND is_active = 1 " +
        "AND (start_date IS NULL OR start_date <= #{date}) " +
        "AND (end_date IS NULL OR end_date >= #{date})")
    List<TerPricingRule> selectActiveRules(@Param("roomTypeId") Long roomTypeId,
                                           @Param("date") LocalDate date);
}
